$("#window-resizer-tooltip").addClass("hidden-print");
//给String增加一个方法,检查字符串是否以string开始
String.prototype.strStartWith = function (string) {
    var reg = new RegExp("^" + string);
    return reg.test(this);
}

function log(a) {
    console.log(a);
}

//给date对象增加format方法
Date.prototype.format = function (formatStr) {
    var str = formatStr;
    var Week = ['日', '一', '二', '三', '四', '五', '六'];

    str = str.replace(/yyyy|YYYY/, this.getFullYear());
    str = str.replace(/yy|YY/, (this.getYear() % 100) > 9 ? (this.getYear() % 100).toString() : '0' + (this.getYear() % 100));

    var month = this.getMonth() + 1;
    str = str.replace(/MM/, month > 9 ? month.toString() : '0' + month);
    str = str.replace(/M/g, month);

    str = str.replace(/w|W/g, Week[this.getDay()]);

    str = str.replace(/dd|DD/, this.getDate() > 9 ? this.getDate().toString() : '0' + this.getDate());
    str = str.replace(/d|D/g, this.getDate());

    str = str.replace(/hh|HH/, this.getHours() > 9 ? this.getHours().toString() : '0' + this.getHours());
    str = str.replace(/h|H/g, this.getHours());
    str = str.replace(/mm/, this.getMinutes() > 9 ? this.getMinutes().toString() : '0' + this.getMinutes());
    str = str.replace(/m/g, this.getMinutes());

    str = str.replace(/ss|SS/, this.getSeconds() > 9 ? this.getSeconds().toString() : '0' + this.getSeconds());
    str = str.replace(/s|S/g, this.getSeconds());

    return str;
}

//距离当前时间的天数
function difDay(timestamp){
	var difference = Math.abs(new Date() - timestamp);
	return Math.round(difference/1000 / 60 / 60 /24);
}

//初始化toastr
toastr.options = {
    closeButton: false,
    debug: false,
    progressBar: false,
    positionClass: "toast-top-right",
    onclick: null,
    showDuration: "300",
    hideDuration: "1000",
    timeOut: "2000",
    extendedTimeOut: "1000",
    showEasing: "swing",
    hideEasing: "linear",
    showMethod: "fadeIn",
    hideMethod: "fadeOut"
};

/**
 * 向cookie中加值
 * @param      {string}  name
 * @param      {string}  val
 */
function setCookie(name,val){
    $.cookie(name,val);
}

/**
 * 获取cookie中的值.
 * @param      {string}  name
 * @return     {string}  val
 */
function getCookie(name){
    return $.cookie(name);
}

/**
 * 删除cookie中的值
 * @param      {string}  name
 */
function removeCookie(name){
    $.cookie(name,"");
}

/**
 * textarea输入剩余字符实时计算
 * textarea不为空的时候,附加一键清空textarea功能
 * hide为bootstrap中定义的class,所以需要引用bootstrap
 * @param textarea     #id or .class
 * @param maxLength    textarea的最大输入长度
 */
function wordsCount(textarea,maxLength){
    var parent = $(textarea).parent();
    parent.css("position","relative");
    var i_tar = $("<i class='iconfont icon-del1'></i>");
    i_tar.appendTo(parent).css({
        "position":"absolute",
        "bottom":"0",
        "left":".5rem",
        "color":"red",
        "font-size":"2rem"}).addClass("hide").attr("title","一键清空");
    var ins_tar = $("<ins><var></var>" + "/" + "<em>" + maxLength + "</em></ins>");
    ins_tar.appendTo(parent).css({
        "position":"absolute",
        "bottom":"0",
        "right":"1rem",
        "font-weight":"bold",
        "background-color":"rgb(0,200,0)",
        "color":"#fff",
        "border-radius":"15px",
        "padding":"0 10px"});
    var va = parent.find("var");
    var i = parent.find(".icon-del1");
    var ins = parent.find("ins");
    i.on("click",function(){
        $(textarea).val("");
        $(textarea).trigger("propertychange");
        $(this).addClass("hide");
    })
    va.text(maxLength);
    $(textarea).attr("maxlength", maxLength);
    $(textarea).on("input propertychange",function(){
        var enterNum = $(textarea).val().split('\n').length;
        var enterLength = $(textarea).val().length - enterNum;
        var overplusLength = maxLength - enterLength - 1;
        var r = Math.floor((enterLength/maxLength)*255);
        var g = Math.floor((overplusLength/maxLength)*200);
        va.text(overplusLength);
        ins.css("background-color","rgb(" + r + "," + g + ",0)");
        va.text() == maxLength ? i.addClass("hide") : i.removeClass("hide");
    })
}

/**
 * 初始化单选复选框
 * @param      {string}  skins   单选复选框皮肤
 * @param      {string}  color   单选复选框颜色
 */
function icheckInit(skins,color){
    $('input').iCheck({
        checkboxClass: "icheckbox_" + skins + "-" + color,
        radioClass: "iradio_" + skins + "-" + color
    })
}

/**
 * 获取url中查询字符串的值
 * @param paramName
 * @returns paramValue
 */
function getUrlParam(paramName){
    var reg = new RegExp("(^|&)" + paramName + "=([^&]*)(&|$)");
    var paramValue = window.location.search.substr(1).match(reg);
    if (paramValue != null) return decodeURI(paramValue[2]);
    return null;
}

/**
 * 将url的查询字符串转换为json对象
 * @param url
 * @returns json
 */
function urlParam2json(url){
    var str = url.split("?")[1];
    var iterms = str.split("&");
    var arr = [],
        Json = {};
    for(var i = 0;i<iterms.length;i++){
        arr = iterms[i].split("=");
        Json[arr[0]] = arr[1];
    }
    return Json;
}

/**
 * 给url中增加参数
 * @param map(参数对象)
 */
function addUrlParam(map){
    var nowUrl = window.location.href,
        baseUrl = "",
        params = "",
        oldParams = [];
    var idx = nowUrl.indexOf("?");
    //如果有查询参数
    if (idx > 0) {
        baseUrl = nowUrl.substr(0, idx);
        //拆分原url中的查询参数
        oldParams = nowUrl.substring(idx + 1, nowUrl.length).split("&");
    } else {
        //如果没有查询参数
        baseUrl = nowUrl;
    }
    //遍历传入的新参数
    $.each(map, function (key, value) {
        //原查询参数中是否有新传的参数名
        var paramNmae = getUrlParam(key);
        //如果原查询参数中有新传的参数名,则先把拆分的原查询参数数组中
        //对应的参数值重置为空
        if (paramNmae != null) {
            $.each(oldParams, function (idx, val) {
                if (val.strStartWith(key + "=")) {
                    oldParams[idx] = '';
                }
            });
        }
        //拼接新传进来的参数到参数字符串
        if (params.length > 0) {
            params += "&";
        }
        params += key + "=" + value;
    });
    //把原拆分的参数数组中非空的项目拼接进参数字符串中
    $.each(oldParams, function (i, v) {
        if (v != '') {
            if (params.length > 0) {
                params += "&";
            }
            params += v;
        }
    });
    //用新拼接的查询参数字符串重新组成url
    nowUrl = baseUrl + "?" + params;
    //替换当前url
    window.history.replaceState(null, null, nowUrl);
}

/**
 * 重置查询参数
 * @param map(参数对象)
 */
function setUrlParam(map){
    var nowUrl = window.location.href,
        baseUrl = "",
        params = "";
    //如果存在查询参数
    var idx = nowUrl.indexOf("?");
    if (idx > 0) {
        baseUrl = nowUrl.substr(0, idx);
    } else {
        baseUrl = nowUrl;
    }
    //遍历新传进来的查询参数到查询参数字符串中
    $.each(map, function (key, value) {
        if (params.length > 0) {
            params += "&";
        }
        params += key + "=" + value;
    });
    //用新拼接的查询参数字符串重新组成url
    nowUrl = baseUrl + "?" + params;
    //替换当前url
    window.history.replaceState(null, null, nowUrl);
}

/**
 * 加密患者姓名,姓名的第一个字符后面的字
 * 替换成**
 * @param name
 * @returns 加密后的名字
 */
function encryptName(name) {
    if (!name){
        return null;
    }
    return name.substring(0,1) + "**";
}

/**
 * 获取性别
 * @param sexremark 性别的标识字符 female or male
 * @returns 性别
 */
function getSex(sexremark){

    switch (sexremark){
        case "female":
            return "女";
            break;
        case "male":
            return "男";
            break;
        default:
            return "未知";
            break;
    }
}

/**
 * 获取患者的医保类型
 * @param typeremark 医保的标识字符
 * @returns 医保类型
 */
function getInsuranceType(typeremark){
    switch (typeremark){
        case 0:
            return "自费";
            break;
        case 1:
            return "医保";
            break;
        case 2:
            return "工伤";
            break;
        default:
            return "未知";
    }
}

/**
 * set_age 根据时间戳计算年龄
 * @param {int} timestamp 时间戳
 */
function setAge(timestamp){
    var t = timestamp ? timestamp : 0;
    if (!t) {return false;}
    var old_year = Number(moment(t).format('YYYY')),
        now_year = Number(moment().format('YYYY')),
        old_month = Number(moment(t).format('M')),
        now_month = Number(moment().format('M')),
        old_day = Number(moment(t).format('D')),
        now_day = Number(moment().format('D'));
    if (now_year > old_year) {
        return now_year - old_year + "岁";
    } else if (now_year == old_year && now_month > old_month) {
        return now_month - old_month + "月";
    } else if (now_year == old_year && now_month == old_month) {
        return "不足月";
    }
}

/**
 * 把日期字符串格式化为年月日时分秒的日期
 * @param 日期字符串   支持格式:"2016-10-15 08:30" 或 "2016/10/15 08:30"
 * @returns 年月日时分秒的日期
 */
function getDate(date){
    if(typeof(date) == "undefined" || !date) {
        return new Date();
    }
    if(date instanceof  Date || typeof(date) == "number") {
        return new Date(date);
    } else if(typeof(date) == "string") {
        var year = "",
            month = "",
            day = "",
            hour = "",
            min = "";
        var c = "";
        date.indexOf("/") != -1 ? c = "/" : c = "-";
        var array = date.split(" ");
        if(typeof(array[0]) != "undefined" &&  array[0]) {
            var dateArray = array[0].split(c);
            year = dateArray[0];
            month = dateArray[1];
            day = dateArray[2];
        }
        if(typeof(array[1]) != "undefined" &&  array[1]) {
            var timeArray = array[1].split(":");
            hour = timeArray[0];
            min = timeArray[1];
        }
        if(year == "" && hour == "") {
            return null;
        }
        else {
            return new Date(year, month-1, day, hour, min, "0");
        }
    } else {
        return null;
    }
}

/**
 * 加密患者患者编号
 * @param element dom
 * @param startIdx 截取起始位置
 * @param amount  截取长度
 * @param insertString 替换的字符
 * @returns 重新给dom元素赋值
 */
function encryptEmrNumber(element,startIdx,amount,insertString){
    if (!$(element)){
        console.log("输入了错误的id或class,正确的输入格式为#id或.class")
        return false;
    }
    if (typeof(startIdx) !="number"){
        console.log("起始位置参数应该为数字类型")
        return false;
    }
    if (typeof(amount) !="number"){
        console.log("截取长度参数应该为数字类型")
        return false;
    }
    var number = $(element).val();
    var mid = number.split("");
    mid.splice(startIdx,amount,insertString);
    var new_num = mid.join("");
    return $(element).val(new_num);
}

/**
 * 加密患者患者编号
 * @param number 患者编号
 * @param startIdx 截取起始位置
 * @param amount  截取长度
 * @param insertString 替换的字符
 * @returns 重新给dom元素赋值
 */
function encryptNumber(number,startIdx,amount,insertString){
    var mid = number.split("");
    mid.splice(startIdx,amount,insertString);
    var new_num = mid.join("");
    return new_num;
}


/**
 * 判断患者编号是否是数字或英文字符
 * @param str
 */
function isNumberOrLetter(str) {
    var patt = /^[0-9a-zA-Z]*$/g;
    if(str != null && str != "" && patt.test(str)) {
        return true;
    }
    else {
        seToastr("error","患者编号只能是字母与数字");
        return false;
    }
}

/**
 * 获取完整的url地址
 * @param pathname urlpath
 * @returns 完整的url地址
 */
/*function getFullUrl(pathname) {
    var host = getCookie("lucy.host"),
        httpPort = getCookie("lucy.http.port"),
        httpsPort = getCookie("lucy.https.port");
    if (!host) {
        host = window.location.hostname;
    }

    if (!httpPort) {
        httpPort = window.location.port;
    }

    if (!httpsPort) {
        httpsPort = window.location.port;
    }

    if (window.location.protocol == "https:") {
        return "https://" + host + ":" + httpsPort + pathname;
    } else {
        return "http://" + host + ":" + httpPort + pathname;
    }
}*/

/*function buildUrl(pathname){
    return "http://172.28.6.112:8088" + pathname;
}*/

/**
 * 发起ajax请求
 * @param urlpath url的相对地址
 * @param data 需要提交的参数或数据
 * @param success 请求成功的回调函数
 * @param fail 请求失败的回调函数
 * @param method 请求方法,不填写默认为get
 * @param async 请求方式,不填写默认为异步
 */
function startAjax(urlpath,data,success,fail,method,async){
    var dataObj = {};
    data.token = getUrlParam("token");
    if(!$.isFunction(arguments[2])){
        setToastr("error","未定义请求成功后的回调");
        return false;
    }

    if(!$.isFunction(arguments[3])){
        setToastr("error","未定义请求失败后的回调");
        return false;
    }

    if (!arguments[4]){
        arguments[4] = "get";
        dataObj = data;
    }else if (arguments[4] == "get"){
        dataObj = data;
    }else if (arguments[4] == "post"
            || arguments[4] == "put"
            || arguments[4] == "delete"){
        dataObj = JSON.stringify(data);
    }else if (arguments[4] && (arguments[4] != "get"
                        || arguments[4] != "post"
                        || arguments[4] != "put"
                        || arguments[4] != "delete")){
        setToastr("error","不被支持的请求方法")
        return false;
    }

    if (!arguments[5]){
        arguments[5] = true;
    }else if (arguments[5] && arguments[5] != true && arguments[5] != false){
        setToastr("error","异步参数设置错误")
        return false;
    }

    $.ajax({
        url: buildUrl(urlpath),
        data: dataObj,
        type: method,
        contentType: "application/json",
        dataType: "json",
        traditional: true,
        async: async,
        timeout: 20000,
        success: function (data) { 
            success(data);
        },
        error: function(err) {
            fail(err);
        }
    });
}

/**
 * * 针对ichecks插件装饰过的单复选框
 * 单击事件发生在label上还是ins上,分别获取对应input的value
 * @param context label + ins 的集合
 * @returns {string}返回对应checkbox或radio的值
 */
function icheckValue(context){
    var value = "";
    if (context[0].tagName == "LABEL"){
        value = context.find("input").val();
    }else if(context[0].tagName == "INS"){
        value = context.prev().val();
    }
    return value;
}

/**
 * 重置form表单时,ichecks装饰过的input的选中样式不会被重置
 * 需要手动重置这些样式
 * @param form 对应form表单的id
 */
function resetIcheck(form){
    $("#" + form).find("ins.iCheck-helper").parent().removeClass("checked");
}

/**
 * 选中特定的radio
 * @param radioParentSelector 目标radio父级元素选择器
 * @param radioName 目标radio的name属性
 * @param radioValue 目标radio的value属性
 */
function checkedRadio(radioParentSelector,radioName,radioValue){
    var radio = radioParentSelector.find(":radio[name =" + radioName + "]");
    var checked_radio = radioParentSelector.find(":radio[name =" + radioName + "][value =" + radioValue + "]");
    checked_radio.prop("checked",true) ;
    if (checked_radio.next().hasClass("iCheck-helper")){
        radio.parent().removeClass("checked");
        checked_radio.parent().addClass("checked");
    }
}

/**
 * 选中特定的checkbox
 * @param radioParentSelector 目标checkbox父级元素选择器
 * @param radioName 目标checkbox的name属性
 */
function checkedCheckBox(checkboxParentSelector,checkboxName){
    var checked_checkbox = checkboxParentSelector.find(":checkbox[name =" + checkboxName + "]");
    checked_checkbox.prop("checked",true) ;
    if (checked_checkbox.next().hasClass("iCheck-helper")){
        checked_checkbox.parent().addClass("checked");
    }
}

/**
 * 选中特定select的选项
 * @param selectSelector 目标select的id 或class
 * @param optionValue 目标select的option选项的value属性
 */
function selectedSelect(selectSelector,optionValue){
    var target = $("#" + selectSelector).length ? $("#" + selectSelector) : $("." + selectSelector);
    target.children("option[value =" + optionValue + "]").prop("selected",true);
}

/**
 * 校验输入框内容长度
 * @param target 目标输入框 id or class
 * @param min 最小长度
 * @param max 最大长度
 * @returns {boolean}
 */
function verifyLength(target,min,max){
    var target = $("#" + target).length ? $("#" + target) : $("." + target);
    var v = target.val().length;
    if (v < min){
        setToastr("error",target.attr("title") + "长度不能小于" + min);
        target.css({"border-color":"red","background-color":"#ccc"});
        return false;
    }else if (v > max){
        setToastr("error",target.attr("title") + "长度不能大于" + max);
        target.css({"border-color":"red","background-color":"#ccc"});
        return false;
    }else{
        return true;
    }
}

/**
 * 校验输入框内容是否为数字
 * @param target 目标输入框
 * @returns {boolean}
 */
function verifyNumber(target){
    var target = $("#" + target).length ? $("#" + target) : $("." + target);
    var v = target.val().trim();
    if (isNaN(v)){
        setToastr("error",target.attr("title") + "必须为数字类型");
        target.css({"border-color":"red","background-color":"#ccc"});
        return false;
    }else{
        return true;
    }
}

/**
 * 校验输入框内容是否为数字并校验数值大小
 * @param target 目标输入框
 * @param min 最小值
 * @param max 最大值
 * @returns {boolean}
 */
function verifyNumVal(target,min,max){
    var target = $("#" + target).length ? $("#" + target) : $("." + target);
    var v = target.val().trim();
    if (isNaN(v)){
        setToastr("error",target.attr("title") + "必须为数字类型");
        target.css({"border-color":"red","background-color":"#ccc"});
        return false;
    }else{
        if (v < min){
            setToastr("error",target.attr("title") + "数值不能小于" + min);
            target.css({"border-color":"red","background-color":"#ccc"});
            return false;
        }else if (v > max){
            setToastr("error",target.attr("title") + "数值不能大于" + max);
            target.css({"border-color":"red","background-color":"#ccc"});
            return false;
        }else{
            return true;
        }
    }
}

/**
 * 校验输入框为必填项
 * @param target 目标输入框
 * @returns {boolean}
 */
function verifyRequested(target){
    var target = $("#" + target).length ? $("#" + target) : $("." + target);
    var v = target.val().trim();
    if (v == ""){
        setToastr("error",target.attr("title") + "为必填项目");
        target.css({"border-color":"red","background-color":"#ccc"});
        return false;
    }else{
        return true;
    }
}

/**
 * 校验日期输入框
 * @param  {String} dateString 输入日期'2017-10-20'
 * @param  {String} separator  日期分隔符'-'
 * @param  {Number} futureDay  可选未来天数
 * @return {boolean}           检验结果
 */
function verifyDateInput(dateString,separator,futureDay){
    //当前时间戳
    var now_date_timestamp = moment().valueOf();
    //实际输入时间戳
    var date_timestamp = moment(dateString).valueOf();
    //时间戳差值
    var difference_timestamp = date_timestamp - now_date_timestamp;
    //时间差值(天数)
    var difference_day = Math.ceil(difference_timestamp/86400000);
    //输入格式匹配正则
    var regExp = /^([1|2]\d{3})-(\d{2})-(\d{2})$/g;
    //匹配正则验证
    var regResult = regExp.test(dateString);
    if (!regResult){
        setToastr("error","日期格式错误,请参考格式'2017-10-05'");
        return false;
    } 
    //拆分输入字符串为数组
    var dateArr = dateString.split(separator);
    //输入的年份和月份
    var year_and_month_str = dateString.slice(0,7);
    //输入的年.月.日
    var year_str = Number(dateArr[0]),
        month_str = Number(dateArr[1]),
        day_str = Number(dateArr[2]);
    //验证月份
    if (month_str < 0 || month_str > 12) {
        setToastr("error","日期格式错误,月份范围0~12");
        return false;
    }
    //验证输入月份的天数
    var daysInMonth = moment(year_and_month_str, "YYYY-MM").daysInMonth();
    if (day_str > daysInMonth) {
        setToastr("error","日期格式错误,输入月份的天数不能大于" + daysInMonth);
        return false;
    }
    //验证可以选择未来几天的日期
    if (difference_timestamp > 0 && futureDay && typeof(futureDay) == "number") {
        if (difference_day > futureDay) {
            setToastr("error","请选择未来" + futureDay + "天内的日期");
            return false;
        }
    }else if (difference_timestamp > 0 && !futureDay){
	alert(1)
        if (difference_day > 0) {
            setToastr("error","不能请选择未来日期");
            return false;
        }
    }
    //验证通过
    return true;
}

/**
 * 计算入院天数,判断是否是新入院患者
 * @param hospitalized_timestamp 入院时间戳
 * @returns {number}入院天数(含当天)
 */
function new_hospitalized(hospitalized_timestamp){
    if (hospitalized_timestamp == null || hospitalized_timestamp == "null") return;
    var now_time = moment().valueOf();
    var hospitalized_time = hospitalized_timestamp;

    console.log(new Date(hospitalized_time))
    
    var base_time_stamp = moment(moment(hospitalized_time).format("YYYY-MM-DD")).add(1,"day").valueOf();
    
    var difference_time = now_time - base_time_stamp;
    
    return Math.ceil(difference_time/1000 / 60 / 60 /24) + 1;
}

/**
 * 获取浏览器高度和宽度
 * @returns 返回浏览器高度和宽度
 */
function getWindowSize(){
    var w=window.innerWidth|| document.documentElement.clientWidth|| document.body.clientWidth;
    var h=window.innerHeight|| document.documentElement.clientHeight|| document.body.clientHeight;
    return {
        winodwInnerWidth:w,
        windowInnerHeight:h
    }
}

// echart饼图色块标识
var colorArr = [
	{
	    name:"物理治疗组",
	    color:"#33CC66"
	},
	{
	    name:"作业治疗组",
	    color:"#3399FF"
	},
	{
	    name:"儿童治疗组",
	    color:"#FF0000"
	},
	{
	    name:"理疗治疗组",
	    color:"#9966CC"
	},
	{
	    name:"言语治疗组",
	    color:"pink"
	}
];

/**
 * 动态设置echart饼图色块标识
 * @param nameArr echart展示内容name数组
 * @param colorArr 颜色数组
 * @returns {array}返回echart饼图色块标识
 */
function getColorArray(nameArr,colorArr){
    var arr = [];
    $.each(nameArr,function(names,name){
	$.each(colorArr,function(colors,color){
	    if(name == color.name){
		arr.push(color.color)
	    }
	})
    })
    return arr;
}

/**
 * 获取登录用户角色id
 * @returns {number}返回登录用户的角色id
 */
function getUserRole() {
    return JSON.parse(getCookie("profile")).institution.role.id;
}
/**
 * 病例页面查看详情时是否显示编辑或删除按钮
 * @param data 查询患者基本信息时返回的数据
 */
function showEditOrDelBtn(data){
    
    var time = data.create_time ? data.create_time : data.check_time;
   
    if(getUserRole() == "2" || (getUserRole() == "3" && new_hospitalized(time) <= 3)){
        if (data.able_to_edit) $("#operate .edit-btn").removeClass("hide");
        if (data.able_to_delete) $("#operate .del-btn").removeClass("hide");
    }
}

/**
 * 
 * @param len uuid长度
 * @param radix  进制
 * @returns
 */
function setUuid(len, radix) {
    var chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split('');
    var uuid = [], i;
    radix = radix || chars.length;
 
    if (len) {
      // Compact form
      for (i = 0; i < len; i++) uuid[i] = chars[0 | Math.random()*radix];
    } else {
      // rfc4122, version 4 form
      var r;
 
      // rfc4122 requires these characters
      uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-';
      uuid[14] = '4';
 
      // Fill in random data.  At i==19 set the high bits of clock sequence as
      // per rfc4122, sec. 4.1.5
      for (i = 0; i < 36; i++) {
        if (!uuid[i]) {
          r = 0 | Math.random()*16;
          uuid[i] = chars[(i == 19) ? (r & 0x3) | 0x8 : r];
        }
      }
    }
 
    return uuid.join('');
}

function getPrivatePatientName(name) {
    if (name == null || name == ""){
        return null;
    }
    return name.substring(0,1) + "**";
}



/**
 * 重定义toastr插件
 * 同样的提示信息值显示一条,避免恶意频繁点击按钮导致
 * 同样的提示信息多次出现
 */
var setToastr = function setToastr(type,mes){
        var m = "";
        return function(type,mes){
            switch (type){
                case "error":
                    toastr.error(mes);
                    break;
                case "warning":
                    toastr.warning(mes);
                    break;
                case "success":
                    toastr.success(mes);
                    break;
            }
            if (m != mes) {
                m = mes;
            }else {
                $(".toast").prev().remove();
            }
        }
    }()